import Layout from "@/components/layout/Layout.vue";
/**
 * 路由 meta 信息说明
 * meta: { name: "", index: "", hideName: false, backIcon:true, hideBreadcrumb: false,
 * roles:[] 没声明说明不做权限校验，声明后只有包含的角色才能加载该路由}
 * name: 路由名称， index: 有子路由时指定默认页, hideName: 隐藏页面标题，backIcon:是否有返回icon, hideBreadcrumb: 隐藏面包屑,
 */
export const routes = [
  {
    path: "/login",
    alias: "",
    component: () =>
      import(/* webpackChunkName: "login" */ "@/views/login/Index.vue")
  },
  {
    path: "/404",
    component: () => import("@/views/errorPage/404")
  },
  {
    path: "*",
    redirect: "/404"
  }
];

export const asyncRoutes = [
  {
    path: "/owner",
    component: Layout,
    children: [
      {
        path: "index",
        meta: {
          name: "业主管理",
          hideName: true
        },
        component: () =>
          import(/* webpackChunkName: "owner" */ "@/views/owner/Index.vue")
      }
    ]
  },
  {
    path: "/order",
    component: Layout,
    meta: {
      name: "工单汇览",
      index: "index"
    },
    children: [
      {
        path: "index",
        meta: {
          name: "工单汇览",
          hideName: true
        },
        component: () =>
          import(/* webpackChunkName: "order" */ "@/views/order/Index.vue")
      },
      {
        path: "topic",
        meta: {
          name: "主题类型管理 (上限6个)",
          backIcon: true
        },
        component: () =>
          import(/* webpackChunkName: "order" */ "@/views/order/Topic.vue")
      }
    ]
  },
  {
    path: "/stall",
    component: Layout,
    children: [
      {
        path: "index",
        meta: {
          name: "车位管理",
          hideName: true
        },
        component: () =>
          import(/* webpackChunkName: "stall" */ "@/views/stall/Index.vue")
      }
    ]
  },
  {
    path: "/vote",
    component: Layout,
    meta: {
      name: "投票管理",
      index: "index",
      roles: [process.env.VUE_APP_SUPER, process.env.VUE_APP_JD]
    },
    children: [
      {
        path: "index",
        meta: {
          name: "投票管理",
          hideName: true
        },
        component: () =>
          import(/* webpackChunkName: "vote" */ "@/views/vote/Index.vue")
      },
      {
        path: "add",
        meta: {
          name: "投票新增",
          backIcon: true
        },
        component: () =>
          import(/* webpackChunkName: "vote" */ "@/views/vote/AddEdit.vue")
      },
      {
        path: "edit",
        meta: {
          name: "投票编辑",
          backIcon: true
        },
        component: () =>
          import(/* webpackChunkName: "vote" */ "@/views/vote/AddEdit.vue")
      },
      {
        path: "detail",
        meta: {
          name: "投票详情",
          backIcon: true
        },
        component: () =>
          import(/* webpackChunkName: "vote" */ "@/views/vote/Detail.vue")
      }
    ]
  },
  {
    path: "/community",
    component: Layout,
    meta: {
      name: "小区管理",
      index: "index"
    },
    children: [
      {
        path: "index",
        meta: {
          name: "小区管理",
          hideName: true
        },
        component: () =>
          import(
            /* webpackChunkName: "community" */ "@/views/community/Index.vue"
          )
      },
      {
        path: "floor",
        meta: {
          name: "楼宇管理",
          backIcon: true
        },
        component: () =>
          import(
            /* webpackChunkName: "community" */ "@/views/community/Floor.vue"
          )
      }
    ]
  },
  {
    path: "/account",
    component: Layout,
    meta: {
      roles: [process.env.VUE_APP_SUPER]
    },
    children: [
      {
        path: "index",
        meta: {
          name: "管理员账号管理",
          hideName: true
        },
        component: () =>
          import(/* webpackChunkName: "account" */ "@/views/account/Index.vue")
      }
    ]
  },
  {
    path: "/log",
    component: Layout,
    meta: {
      roles: [process.env.VUE_APP_SUPER]
    },
    children: [
      {
        path: "index",
        meta: {
          name: "访问日志",
          hideName: true
        },
        component: () =>
          import(/* webpackChunkName: "log" */ "@/views/log/Index.vue")
      }
    ]
  }
];
